package D2;

public class OutClass {

    private int a;
    static int b;

    public void methodA(){
        a = 10;
        System.out.println(a);
    }

    public static void methodB(){
        System.out.println(b);
    }
    //静态内部类
    static class InnerClass{
        public int a;
        public int c = 30;

        public void methodInner1(){
            //在内部类中只能访问外部类的静态成员
            //methodA();
            //如果要访问，需要借助对象的引用来访问
            OutClass outClass1 = new OutClass();
            outClass1.a = 100;
            a = 30;
            System.out.println(outClass1.a);//访问的是外部类的a; 输出100
            System.out.println(a);//访问的是内部类的a; 输出30

            outClass1.methodA();//输出10

            b = 30;
            methodB();//输出30

        }
    }

    public static void main(String[] args) {
        OutClass.InnerClass innerClass1 = new OutClass.InnerClass();//静态内部类的实例
        innerClass1.methodInner1();//静态内部类的访问
    }
}
